package com.xiaochun.jiankangapp.activity

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.Target
import com.xiaochun.jiankangapp.base.BaseActivity
import com.xiaochun.jiankangapp.databinding.ActivityImagePreviewBinding
import com.xiaochun.jiankangapp.extension.loadUrl

class ImagePreviewActivity : BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val viewBinding: ActivityImagePreviewBinding = setContentView()
        val path = intent.getStringExtra("path")

        path?.let {
            Glide.with(this).load(it).override(Target.SIZE_ORIGINAL).into(viewBinding.image)
        }
    }

    companion object {
        @JvmStatic
        fun start(context: Context, path: String?) {
            context.startActivity(
                Intent(context, ImagePreviewActivity::class.java).putExtra(
                    "path",
                    path
                )
            )
        }
    }
}